import { useGlobalStore } from '~/store';
import { getLangFromQuery } from '~/utils';
export const useMessage = (
    translationFiles: Record<string, Record<string, any>> | Record<string, Record<string, any>>[]
): void => {
    if (process.server) return;
    const store = useGlobalStore();
    const lang = getLangFromQuery();
    if (Array.isArray(translationFiles)) {
        for (let i = 0; i < translationFiles.length; i++) {
            const targetMessages = translationFiles[i]?.[lang] || {};
            store.messages = {
                ...store.messages,
                ...targetMessages,
            };
        }
    } else {
        const targetMessages = translationFiles?.[lang] || {};
        store.messages = {
            ...store.messages,
            ...targetMessages,
        };
    }
};
